<?php

 $mapLevel = get_post_meta($post->ID, 'baidu_map_level', true);  echo empty($mapLevel)?13:$mapLevel;
 $mapLevel =  empty($mapLevel)?13:$mapLevel;
 
 $absolutePositions = get_post_meta($post->ID, 'baidu_absolute_position', true);
 $absolutePositions = $absolutePositions or "0,0";
 $absolutePositions = split(",",$absolutePositions);
 
 $title =  get_post_meta($post->ID, 'mall_name', true) or "";
 
 $content = get_post_meta($post->ID, 'mall_detail', true) or "";

?>


<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
<script type="text/javascript">
$(function (){
var map = new BMap.Map("baidu-map");
map.centerAndZoom("深圳",10);  

setTimeout(function(){
	var absolutePositions  = [<?php echo $absolutePositions[0]?>,<?php echo $absolutePositions[1]?>],
		mapLevel = <?php  echo $mapLevel ?>,
		title = "<?php  echo $title; ?>",
		content = "<?php echo $content?>",
		point = new BMap.Point(absolutePositions[0],absolutePositions[1]),
		url = 'http://api.map.baidu.com/marker?location=' + absolutePositions[1] + ',' + absolutePositions[0] + '&title=' + title + '&content=' + content + '&output=html';

	if(absolutePositions[0] === '0' && bsolutePositions[1] === '0'){
		return ;
	}
		
    map.centerAndZoom(point,mapLevel);  
    
	var marker = new BMap.Marker(point);  
	marker.setTitle(title);
	marker.addEventListener("click", function (e) {
		window.open(url);
	}) ;

	$("a.baidu-map-open").click(function(){
		window.open(url);
	});
	map.addOverlay(marker);          
}, 1500);


});
</script>